arm: add a function to invoke the PSCI handler
authorAndre Przywara <andre.przywara@linaro.org>
Thu, 5 Dec 2013 10:08:10 +0000 (11:08 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Thu, 5 Dec 2013 12:25:13 +0000 (12:25 +0000)
The PSCI handler is invoked via a secure monitor call with the
arguments defined in registers. Copy the function from the
Linux code and adjust it to work on both ARM32 and ARM64.

Signed-off-by: Andre Przywara <andre.przywara@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
xen/arch/arm/psci.c
xen/include/asm-arm/psci.h

index efb514e4bc812db3b83ce89798f1fd3c82a55ffa..25a869769dc016640c134011dfc746492c287db8 100644 (file)
 
 bool_t psci_available;
 
+#ifdef CONFIG_ARM_32
+#define REG_PREFIX "r"
+#else
+#define REG_PREFIX "x"
+#endif
+
+static noinline int __invoke_psci_fn_smc(register_t function_id,
+                                         register_t arg0,
+                                         register_t arg1,
+                                         register_t arg2)
+{
+    asm volatile(
+        __asmeq("%0", REG_PREFIX"0")
+        __asmeq("%1", REG_PREFIX"1")
+        __asmeq("%2", REG_PREFIX"2")
+        __asmeq("%3", REG_PREFIX"3")
+        "smc #0"
+        : "+r" (function_id)
+        : "r" (arg0), "r" (arg1), "r" (arg2));
+
+    return function_id;
+}
+
+#undef REG_PREFIX
+
 static uint32_t psci_cpu_on_nr;
 
+int call_psci_cpu_on(int cpu)
+{
+    return __invoke_psci_fn_smc(psci_cpu_on_nr, cpu, __pa(init_secondary), 0);
+}
+
 int __init psci_init(void)
 {
     const struct dt_device_node *psci;
index 36ce87da4142b9d87b920c5ba5885c0007e79d2e..189964bfadab0a0f6fa94a1f6459ab5002f1d121 100644 (file)
@@ -10,6 +10,7 @@
 extern bool_t psci_available;
 
 int psci_init(void);
+int call_psci_cpu_on(int cpu);
 
 /* functions to handle guest PSCI requests */
 int do_psci_cpu_on(uint32_t vcpuid, register_t entry_point);